package Model

import "time"

type Employee struct {
	itsEmployeeId int
	itsName string
	itsAddress string
	itsClassification PaymentClassification
	itsSchedule PaymentSchedule
	itsPaymentMethod PaymentMethod
	itsAffiliation Affiliation
}

func (e *Employee) GetItsAffiliation() Affiliation {
	return e.itsAffiliation
}

func (e *Employee) SetItsAffiliation(itsAffiliation Affiliation) {
	e.itsAffiliation = itsAffiliation
}

func NewEmployee(employeeId int, name string, address string) Employee {
	return Employee{
		itsEmployeeId : employeeId,
		itsName : name,
		itsAddress : address,
	}
}

func (e *Employee) GetName() string {
	return e.itsName
}

func (e *Employee) SetName(itsName string) {
	e.itsName = itsName
}

func (e *Employee) GetAddress() string {
	return e.itsAddress
}

func (e *Employee) SetAddress(itsAddress string) {
	e.itsAddress = itsAddress
}

func (e *Employee) GetEmployeeId() int {
	return e.itsEmployeeId
}

func (e *Employee) SetEmployeeId(itsEmployeeId int) {
	e.itsEmployeeId = itsEmployeeId
}

func (e *Employee) SetItsClassification(pc PaymentClassification) {
	e.itsClassification = pc
}

func (e *Employee) GetClassification() PaymentClassification {
	return e.itsClassification
}

func (e *Employee) SetItsSchedule(ps PaymentSchedule) {
	e.itsSchedule = ps
}

func (e *Employee) GetSchedule() PaymentSchedule {
	return e.itsSchedule
}

func (e *Employee) SetItsPaymentMethod(pm PaymentMethod) {
	e.itsPaymentMethod = pm
}

func (e *Employee) GetPaymentMethod() PaymentMethod {
	return e.itsPaymentMethod
}

func (e *Employee) IsPayDate(payDate time.Time) bool {
	return e.itsSchedule.IsPaydate(payDate)
}

func (e *Employee) GetPayPeriodStartDate(payPeriodEndDate time.Time) time.Time {
	return e.itsSchedule.GetPayPeriodStartDate(payPeriodEndDate)
}

func (e *Employee) Payday(pc Paycheck) {
	grossPay := e.itsClassification.CalculatePay(pc)
	deductions := e.itsAffiliation.CalculateDeduction(pc)
	netPay := grossPay - deductions
	pc.SetGrossPay(grossPay)
	pc.SetDeductions(deductions)
	pc.SetNetPay(netPay)
	e.itsPaymentMethod.Pay(pc)
}